﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ICSharpCode.SharpZipLib.Zip;
using System.IO;

namespace SharpZipLibFastZip
{
    class Program
    {
        static void Main(string[] args)
        {
            CreateFilesAndDirectiries();
            FastZip zip = new FastZip();

            // zip

            zip.CreateZip("my.zip","ToZip", true,null);

            // unzip

            zip.ExtractZip("my.zip", "New", null);

        }

        private static void CreateFilesAndDirectiries()
        {
            Directory.CreateDirectory("ToZip");
            List<FileStream> files = new List<FileStream>();
            files.Add(File.Create("ToZip\\file1.txt"));
            files.Add(File.Create("ToZip\\file2.txt"));
            files.ForEach(FillHelloWorldInStream);
            files.ForEach(fStream => fStream.Close());
        }

        private static void FillHelloWorldInStream(FileStream file)
        {
            byte[] buffer = Encoding.UTF8.GetBytes("Hello World");
            file.Write(buffer, 0, buffer.Length);
        }
    }
}
